Conversation
Extracts the three Kotlin blocks from the Quick Settings tiles guide into views/.../quicksettings/QuickSettingsTilesSnippets.kt. Two of the three blocks do not compile as published, and each is corrected by one line: - Update your tile sets the content description from tile.label, and the Kotlin block declares no tile. The Java block on the same page declares Tile tile = getQsTile(). The snippet reads state.label instead, so every right-hand side in the block comes from the model the block declares. - Handle taps declares var clicks = 0 and then increments counter four times. The snippet names the declaration counter, which changes one line rather than four. Both need a page edit either way. The pull request description says so, and gives the alternative for each.
hamen
marked this pull request as ready for review
September 11, 2026 16:05
|
Here is the summary of changes. You are about to add 3 region tags.
This comment is generated by snippet-bot.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Code snippets are for: Quick Settings tiles
Three Kotlin blocks, into
views/src/main/java/com/example/example/snippet/views/quicksettings/QuickSettingsTilesSnippets.kt.android_views_quicksettings_tile_serviceandroid_views_quicksettings_update_tileandroid_views_quicksettings_handle_tapsspotlessApplychanged indentation from two spaces to four and added a space inclass MyQSTileService : TileService(). No line counts changed.List of modifications
Two blocks on the page do not compile, and each needed one line changed.
Update your tile sets the content description from
tile.label, and the Kotlin block declares notile. Every other line in the block usesqsTile. The Java block on the same page declaresTile tile = getQsTile()and then usestile, so the Kotlin block reads like a translation that lost the local variable and kept one use of it. Building the published lines givesUnresolved reference 'tile'.The snippet reads
state.label, which is the value assigned toqsTile.labelone line earlier, so every right-hand side in the block comes from the model the block declares.The page can be repaired either way: give the Kotlin block the
Tile tile = getQsTile()line its Java sibling already has, or read fromstateas this snippet does.Handle taps declares
var clicks = 0and then incrementscounterfour times. Building the published lines gives fourUnresolved reference 'counter'errors. The snippet names the declarationcounter, which changes one line instead of four. Naming the four usesclicksis equally correct — please use whichever name reads better on the page.Both blocks need a page edit either way. A reader who copies them today gets a compile error.
How the file is arranged
StateModelsits insideUpdateTileServicerather than at the top level. The page shows the data class, a blank line, then the override; two spans of one region tag cannot keep that blank line, and the published snippet would come out a line shorter. One span keeps it. The nesting does not change what the page shows.getStateFromService()is outside the region tags. The page calls it in both the Kotlin and the Java block and never defines it, so it reads as an app function rather than a platform API. The stub is here only so the module compiles.The three regions live in three subclasses of
TileService, not one. The first block overridesonStartListening()andonClick(), the second overridesonStartListening(), the third overridesonClick(). The second and third cannot share the first class.Snippets not migrated
No other block on the page carries a region tag. Line numbers are from
quicksettings-tiles.md.txt.Keep the block at line 513: it shows the signature of
requestAddTileService()and is reference text, not an example a reader copies.The block at line 420 adds
Intent.FLAG_ACTIVITY_NEW_TASK. It sits in the prose rather than under a Kotlin or Java heading, so it reads as an example for both languages, but it carries a semicolon, which makes it Java as written. Removing the semicolon makes it Kotlin and it stays correct for a Java reader. That is a page decision, so nothing here changes it.The four XML manifest examples are not Kotlin and this change does not extract them. The one at line 140 has a defect worth fixing while the page is open:
XML has no
//comment, so the example does not parse as printed and a reader who copies it gets a manifest that does not build. Moving the note above the element as<!-- 18-character limit. -->keeps the note and makes the example build. It has no effect on the snippets.